<?php
class Prd_review_log extends CActiveRecord
{
    //定义分表数量
    const PIECES = 32;
    
    public function getDbConnection()
    {
        return Yii::app()->db_log;
    }

    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }
    
    public function tableName()
    {
        return strtolower(get_class($this));
    }

    public static function _dolog($product_id,$score,$comment)
    {
        if(!$product_id)
            return;
        //分表的类名
        $classname = __CLASS__.sprintf('_%02d',$product_id%self::PIECES);
        $newlog = new $classname;
        $newlog->prd_id = $product_id;
        $newlog->score = $score;
        $newlog->comment = $comment;
        $newlog->ip = MyController::getUserHostAddress();
        $newlog->save();
    }
}
class Prd_review_log_00 extends Prd_review_log{}
class Prd_review_log_01 extends Prd_review_log{}
class Prd_review_log_02 extends Prd_review_log{}
class Prd_review_log_03 extends Prd_review_log{}
class Prd_review_log_04 extends Prd_review_log{}
class Prd_review_log_05 extends Prd_review_log{}
class Prd_review_log_06 extends Prd_review_log{}
class Prd_review_log_07 extends Prd_review_log{}
class Prd_review_log_08 extends Prd_review_log{}
class Prd_review_log_09 extends Prd_review_log{}
class Prd_review_log_10 extends Prd_review_log{}
class Prd_review_log_11 extends Prd_review_log{}
class Prd_review_log_12 extends Prd_review_log{}
class Prd_review_log_13 extends Prd_review_log{}
class Prd_review_log_14 extends Prd_review_log{}
class Prd_review_log_15 extends Prd_review_log{}
class Prd_review_log_16 extends Prd_review_log{}
class Prd_review_log_17 extends Prd_review_log{}
class Prd_review_log_18 extends Prd_review_log{}
class Prd_review_log_19 extends Prd_review_log{}
class Prd_review_log_20 extends Prd_review_log{}
class Prd_review_log_21 extends Prd_review_log{}
class Prd_review_log_22 extends Prd_review_log{}
class Prd_review_log_23 extends Prd_review_log{}
class Prd_review_log_24 extends Prd_review_log{}
class Prd_review_log_25 extends Prd_review_log{}
class Prd_review_log_26 extends Prd_review_log{}
class Prd_review_log_27 extends Prd_review_log{}
class Prd_review_log_28 extends Prd_review_log{}
class Prd_review_log_29 extends Prd_review_log{}
class Prd_review_log_30 extends Prd_review_log{}
class Prd_review_log_31 extends Prd_review_log{}
